@extends('Admin.layouts.application')
@section('css')
    <link rel="stylesheet" href="/assets/xSystem/vendor/daterangepicker/daterangepicker.css">

@endsection
@section('content')
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">APP升级管理</strong> /
                    <small>Room information</small>
                </div>
            </div>

            <hr>
            @include('Admin.layouts._flash')
            <div class="am-g" style="height: 37px;">
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            {{--<a type="button" class="am-btn am-btn-success" href="{{url('room/create')}}">
                                <span class="am-icon-plus"></span> 新增
                            </a>--}}
                        </div>
                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">

                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr>
                                <th class="table-id">编号</th>
                                <th class="table-title">app名称</th>
                                <th class="table-title">版本号</th>
                                <th class="table-title">apk</th>
                                <th class="table-title">是否更新</th>
                                <th class="table-title">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($apps as $app)
                                <tr data-id="{{$app->id}}" id="row_{{$app->id}}" class="xParent">
                                    <td>{{$app->id}}</td>

                                    <td>
                                        {{$app->name}}
                                    </td>
                                    <td>
                                        {{$app->number}}
                                    </td>
                                    <td>
                                        {{$app->url}}
                                    </td>


                                    <td class="am-hide-sm-only">
                                        {!! is_something('is_update', $app) !!}
                                    </td>

                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a class="am-btn am-btn-success am-btn-xs am-text-secondary"
                                                   href="{{route('app.edit', $app->id)}}">
                                                    <span class="am-icon-pencil-square-o"></span> 编辑
                                                </a>

                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>

                        <hr/>
                    </form>
                </div>
            </div>
        </div>
        @include('Admin.layouts._footer')

    </div>
@endsection

@section('js')

    <script src="/assets/xSystem/vendor/daterangepicker/moment.js"></script>
    <script src="/assets/xSystem/vendor/moment/locale/zh-cn.js"></script>
    <script src="/assets/xSystem/vendor/daterangepicker/daterangepicker.js"></script>

    <script src="/assets/xSystem/js/daterange_config.js"></script>
    <script>
        $(function () {

            //是否...
            $(".is_something").click(function () {
                var _this = $(this);
                var data = {
                    id: _this.parents("tr").data('id'),
                    attr: _this.data('attr')
                }
                console.log(data);
                $.ajax({
                    type: "PATCH",
                    url: "/app/is_something",
                    data: data,
                    success: function () {
                        _this.toggleClass('am-icon-close am-icon-check');
                    }
                });
            });

            //排序
            $("input[name='sort_order']").change(function () {
                var data = {
                    sort_order: $(this).val(),
                    id: $(this).parents("tr").data('id')
                };
                console.log(data);
                $.ajax({
                    type: "PATCH",
                    url: "/room/sort_order",
                    data: data,
                });
            });

        });
    </script>
@endsection





